using UnityEngine;

public class InAppButton : MonoBehaviour
{
	public UILabel count;

	public CoinsController coinsController;

	protected InAppPurchase.InAppObject inApp;

	public void Init(InAppPurchase.InAppObject inApp)
	{
		this.inApp = inApp;
		string text = string.Empty;
		if (inApp.type == InAppPurchase.ItemType.Coins)
		{
			text = text + GGFormat.FormatPrice(inApp.getsCoins) + " (Coin)";
		}
		else if (inApp.type == InAppPurchase.ItemType.GiraffeDollars)
		{
			text = text + GGFormat.FormatPrice(inApp.getsDollars) + " (G$)";
		}
		else if (inApp.type == InAppPurchase.ItemType.Tokens)
		{
			text += GGFormat.FormatPrice(inApp.getsTokens);
		}
		count.text = "+" + text;
	}

	public void OnClick()
	{
		Debug.Log("Click purchase");
		InAppPurchase.instance.buyProduct(inApp.productId);
		if (coinsController != null)
		{
			coinsController.UpdateCurrency();
		}
	}
}
